package com.ruoyi.web.controller.sxt;

import java.util.List;

import com.ruoyi.sxt.domain.SxtGangwei;
import com.ruoyi.sxt.service.ISxtGangweiService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 岗位信息Controller
 * 
 * @author ruoyi
 * @date 2025-06-27
 */
@Controller
@RequestMapping("/sxt/gangwei")
public class SxtGangweiController extends BaseController
{
    private String prefix = "sxt/gangwei";

    @Autowired
    private ISxtGangweiService sxtGangweiService;

    @RequiresPermissions("sxt:gangwei:view")
    @GetMapping()
    public String gangwei()
    {
        return prefix + "/gangwei";
    }

    /**
     * 查询岗位信息列表
     */
    @RequiresPermissions("sxt:gangwei:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SxtGangwei sxtGangwei)
    {
        //注释岗位分页
        //确定
        //好的
        //对方
        startPage();
        List<SxtGangwei> list = sxtGangweiService.selectSxtGangweiList(sxtGangwei);
        return getDataTable(list);
    }

    /**
     * 导出岗位信息列表
     */
    @RequiresPermissions("sxt:gangwei:export")
    @Log(title = "岗位信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SxtGangwei sxtGangwei)
    {
        List<SxtGangwei> list = sxtGangweiService.selectSxtGangweiList(sxtGangwei);
        ExcelUtil<SxtGangwei> util = new ExcelUtil<SxtGangwei>(SxtGangwei.class);
        return util.exportExcel(list, "岗位信息数据");
    }

    /**
     * 新增岗位信息
     */
    @RequiresPermissions("sxt:gangwei:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存岗位信息
     */
    @RequiresPermissions("sxt:gangwei:add")
    @Log(title = "岗位信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SxtGangwei sxtGangwei)
    {
        return toAjax(sxtGangweiService.insertSxtGangwei(sxtGangwei));
    }

    /**
     * 修改岗位信息
     */
    @RequiresPermissions("sxt:gangwei:edit")
    @GetMapping("/edit/{postId}")
    public String edit(@PathVariable("postId") Long postId, ModelMap mmap)
    {
        SxtGangwei sxtGangwei = sxtGangweiService.selectSxtGangweiByPostId(postId);
        mmap.put("sxtGangwei", sxtGangwei);
        return prefix + "/edit";
    }

    /**
     * 修改保存岗位信息
     */
    @RequiresPermissions("sxt:gangwei:edit")
    @Log(title = "岗位信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SxtGangwei sxtGangwei)
    {
        return toAjax(sxtGangweiService.updateSxtGangwei(sxtGangwei));
    }

    /**
     * 删除岗位信息
     */
    @RequiresPermissions("sxt:gangwei:remove")
    @Log(title = "岗位信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sxtGangweiService.deleteSxtGangweiByPostIds(ids));
    }
}
